package cn.afactory.tygz.ui.base.utils.sns;

import android.content.Context;
import android.util.DisplayMetrics;

/**
 * Created with Android Studio.
 * Title:Tools
 * Description:
 * Copyright:Copyright (c) 2015
 * Company:和平必胜、正义必胜、人民必胜
 * Author:炎黄子孙
 * Date:15/9/22
 * Time:下午9:29
 * Version 1.0
 */
public class Tools {
    public static int dip2px(Context context, int dip) {
        DisplayMetrics dm = context.getResources().getDisplayMetrics();
        return (int) (dip * dm.density + 0.5f);
    }

    public static int px2dip(Context context, float pxValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5f);
    }
}
